<template>
  <van-nav-bar title="查看病历" left-text="返回" left-arrow @click-left="onClickLeft" />
  <div style="margin-top: 20px">
    <van-cell title="问诊科室"> </van-cell>
    <van-cell title="问诊时间">
      {{ visitTime }}
    </van-cell>
    <van-cell title="问诊姓名">
      {{ name }}
    </van-cell>
    <van-cell title="问诊备注" is-link>
      {{ talk }}
    </van-cell>
  </div>
  <div style="margin-top: 20px">
    <van-cell
      center
      title="添加图片"
      label="上传检查单、CT、病历、患处、药品等，春雨会确保您的隐私安全"
      is-link
    />
    <van-uploader v-model="fileList" multiple />
  </div>
  <div>
    <button @click="del()">
      <van-icon name="delete" color="#f56c6c" />
      <span style="color: #f56c6c">删除</span>
    </button>
  </div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
const router = useRouter()
import { ref } from 'vue'
const onClickLeft = () => {
  router.go(-1)
}
const del = () => {
  localStorage.removeItem('name')
  localStorage.removeItem('talk')
  localStorage.removeItem('time')
  router.go(-1)
}
const fileList = ref([
  { url: 'https://fastly.jsdelivr.net/npm/@vant/assets/leaf.jpeg' },
  // Uploader 根据文件后缀来判断是否为图片文件
  // 如果图片 URL 中不包含类型信息，可以添加 isImage 标记来声明
  { url: 'https://cloud-image', isImage: true }
])
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
const visitTime = `${year}-${month}-${day}`
const name = localStorage.getItem('name')
const talk = localStorage.getItem('talk')
</script>
<style>
button {
  width: 100%;
  background-color: white;
  color: red;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  text-align: center;
  margin-top: 20px;
}
</style>
